package services;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.google.gson.Gson;

import entities.Template;

import models.TemplateModel;

public class GetTemplate extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		String id = (String) request.getParameter("id");
		
		TemplateModel templateModel = TemplateModel.getInstance();
		Template template = templateModel.get(id);
		
		Gson gson = new Gson();
		String json = gson.toJson(template);
		
		response.setContentType("text/plain");
        response.getWriter().print(json);
		
	}
}
